home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / pascal / fcsrc.exe / FCINI.PAS < prev    next >
Pascal/Delphi Source File  |  1992-06-04  |  14KB  |  493 lines

  1. unit FCINI;
  2.  
  3. {$R FCINI}
  4.  
  5. interface
  6.  
  7. uses WinTypes, WinProcs, WObjects, WinDOS, Strings, FCDLGS;
  8.  
  9. {$I fc.inc}
  10.  
  11. const
  12.   id_SetupDlg                = 300;
  13.     id_DirEdit                = 301;
  14.     id_FltrEdit                = 302;
  15.     id_PrmEdit                = 303;
  16.     id_AppEdit                = 304;
  17.     id_ItmLabel                = 305;
  18.     id_GrpLabel                = 306;
  19.     id_NeedsAppCheck    = 307;
  20.     id_MinRadio                = 308;
  21.     id_WinRadio                = 309;
  22.     id_MaxRadio                = 310;
  23.   id_AppLabel                = 311;
  24.  
  25.   cm_New                        = 321;
  26.   cm_Open                        = 322;
  27.   cm_Save                        = 323;
  28.   cm_SaveAs                    = 324;
  29.   cm_Install                = 325;
  30.   cm_Use                        = 326;
  31.   cm_Cancel                    = 327;
  32.   cm_FindDir                = 328;
  33.   cm_FindApp                = 329;
  34.   cm_HelpIndex            = 330;
  35.   cm_HelpEdit                = 331;
  36.  
  37.  
  38. type
  39.     PTransferRec = ^TransferRec;
  40.     TransferRec = record
  41.         EDir: array[0..fsPathName] of Char;
  42.         EFltr: array[0..fsFileName+fsExtension] of Char;
  43.         EPrm:    array[0..fsPathName] of Char;
  44.         EApp: array[0..fsPathName] of Char;
  45.         EItm: array[0..PrgManItm] of Char;
  46.     EGrp: array[0..PrgManGrp] of Char;
  47.         CNeedsApp: Word;
  48.         RMin: Word;
  49.         RWin: Word;
  50.         RFull: Word;
  51.         LApp: array[0..LabelLen] of Char;
  52.     end;
  53.  
  54.     PFCSDlg = ^FCSDlg;
  55.     FCSDlg = object(TDialog)
  56.       StartSctnName: array[0..PrgManItm] of Char;
  57.     SctnName: PChar;
  58.     FCSHelpFile: array[0..fsPathName] of Char;
  59.         DirEdit: PEdit;
  60.     FltrEdit: PEdit;
  61.     PrmEdit: PEdit;
  62.         AppEdit: PEdit;
  63.         ItmLabel: PStatic;
  64.     GrpLabel: PStatic;
  65.         NeedsAppCheck: PCheckBox;
  66.     MinRadio: PRadioButton;
  67.     WinRadio: PRadioButton;
  68.     MaxRadio: PRadioButton;
  69.     AppLabel: PStatic;
  70.     NeedsAppIsChecked: Word;
  71.     MinIsChecked: Word;
  72.     WinIsChecked: Word;
  73.     MaxIsChecked: Word;
  74.     NewInstall: boolean;
  75.         constructor Init(AParent: PWindowsObject; ASctnName: PChar);
  76.         procedure SetupWindow; virtual;
  77.         procedure PopMessage(text: PChar);
  78.     procedure CMNew(var Msg: TMessage);
  79.         virtual cm_First + cm_New;
  80.     procedure CMOpen(var Msg: TMessage);
  81.         virtual cm_First + cm_Open;
  82.     procedure CMSave(var Msg: TMessage);
  83.         virtual cm_First + cm_Save;
  84.     procedure CMSaveAs(var Msg: TMessage);
  85.         virtual cm_First + cm_SaveAs;
  86.     procedure CMInstall(var Msg: TMessage);
  87.         virtual cm_First + cm_Install;
  88.     procedure CMUse(var Msg: TMessage);
  89.         virtual cm_First + cm_Use;
  90.     procedure CMCancel(var Msg: TMessage);
  91.         virtual cm_First + cm_Cancel;
  92.     procedure CMFindDir(var Msg: TMessage);
  93.         virtual cm_First + cm_FindDir;
  94.     procedure CMFindApp(var Msg: TMessage);
  95.         virtual cm_First + cm_FindApp;
  96.       procedure CMHelpIndex(var Msg: TMessage);
  97.         virtual cm_First + cm_HelpIndex;
  98.     procedure CMHelpEdit(var Msg: TMessage);
  99.         virtual cm_First + cm_HelpEdit;
  100.     procedure CMNeedsAppCheck(var Msg: TMessage);
  101.         virtual id_First + id_NeedsAppCheck;
  102.     function CanClose: boolean; virtual;
  103.     procedure SetIniData(TheSection: PChar);
  104.     procedure ClearModFlags;
  105.     procedure FixName(AName: PChar);
  106.     procedure SetTitle;
  107.     procedure UpdateCheck;
  108.     end;
  109.  
  110. procedure GetIniData(PTRec: PTransferRec; Section: PChar);
  111.  
  112. implementation
  113.  
  114.  
  115. procedure FCSDlg.PopMessage(text: PChar);
  116. begin
  117.     MessageBox(HWindow, text, 'Message', mb_Ok);
  118. end;
  119.  
  120.  
  121. constructor FCSDlg.Init(AParent: PWindowsObject; ASctnName: PChar);
  122. begin
  123.     TDialog.Init(AParent, PChar(id_SetupDlg));
  124.   SctnName := ASctnName;
  125.   {StrLCopy(SctnName, ASctnName, PrgManItm+1);}
  126.   StrCopy(StartSctnName, SctnName);
  127.     DirEdit := New(PEdit, InitResource(@Self, id_DirEdit, fsPathName+1));
  128.     FltrEdit := New(PEdit, InitResource(@Self, id_FltrEdit, fsFileName+fsExtension+1));
  129.     PrmEdit := New(PEdit, InitResource(@Self, id_PrmEdit, fsPathName+1));
  130.     AppEdit := New(PEdit, InitResource(@Self, id_AppEdit, fsPathName+1));
  131.     ItmLabel := New(PStatic, InitResource(@Self, id_ItmLabel, PrgManItm+1));
  132.     GrpLabel := New(PStatic, InitResource(@Self, id_GrpLabel, PrgManGrp+1));
  133.     NeedsAppCheck := New(PCheckBox, InitResource(@Self, id_NeedsAppCheck));
  134.     MinRadio := New(PRadioButton, InitResource(@Self, id_MinRadio));
  135.     WinRadio := New(PRadioButton, InitResource(@Self, id_WinRadio));
  136.     MaxRadio := New(PRadioButton, InitResource(@Self, id_MaxRadio));
  137.     AppLabel := New(PStatic, InitResource(@Self, id_AppLabel, LabelLen+1));
  138. end;
  139.  
  140. procedure FCSDlg.SetupWindow;
  141. var
  142.     Buffer: array[0..fsPathName] of Char;
  143.   Temp1: array[0..fsFileName] of Char;
  144.   Temp2: array[0..fsExtension] of Char;
  145. begin
  146.     TDialog.SetupWindow;
  147.   StrPCopy(Buffer, ParamStr(0));
  148.   FileSplit(Buffer, FCSHelpFile, Temp1, Temp2);
  149.   if FCSHelpFile[3] = #0 then FCSHelpFile[2] := #0;
  150.   StrCat(FCSHelpFile, '\');
  151.   StrCat(FCSHelpFile, HelpName);
  152.   SetTitle;
  153.   AppLabel^.SetText('Serving &App:');
  154.   MinIsChecked := MinRadio^.GetCheck;
  155.   WinIsChecked := WinRadio^.GetCheck;
  156.   MaxIsChecked := MaxRadio^.GetCheck;
  157.   NeedsAppIsChecked := NeedsAppCheck^.GetCheck;
  158.   UpdateCheck;
  159.   NewInstall := FALSE;
  160. end;
  161.  
  162. procedure FCSDlg.UpdateCheck;
  163. begin
  164.     if NeedsAppCheck^.GetCheck = bf_Checked then
  165.     begin
  166.       EnableWindow(AppLabel^.HWindow, TRUE);
  167.      end
  168.     else
  169.     begin
  170.       EnableWindow(AppLabel^.HWindow, FALSE);
  171.     end;
  172. end;
  173.  
  174. procedure FCSDlg.CMNeedsAppCheck(var Msg: TMessage);
  175. begin
  176.     if Msg.LParamHi = bn_Clicked then UpdateCheck;
  177. end;
  178.  
  179. procedure FCSDlg.CMFindDir(var Msg: TMessage);
  180. var
  181.     TRec: array[0..fsPathName] of Char;
  182.   PD: PDialog;
  183. begin
  184.     PD := New(PDirDlg, Init(@Self, TRec));
  185.   if Application^.ExecDialog(PD) = id_Ok then
  186.   begin
  187.       if TRec[2] = #0 then StrCat(TRec, '\');
  188.       DirEdit^.SetSelection(0, 32767);
  189.     DirEdit^.Insert(StrLower(TRec));
  190.   end;
  191. end;
  192.  
  193. procedure FCSDlg.CMFindApp(var Msg: TMessage);
  194. var
  195.     TRec: array[0..fsPathName] of Char;
  196.   PD: PDialog;
  197. begin
  198.     PD := New(PExeDlg, Init(@Self, TRec));
  199.   if Application^.ExecDialog(PD) = id_Ok then
  200.     begin
  201.       AppEdit^.SetSelection(0, 32767);
  202.     AppEdit^.Insert(StrLower(TRec));
  203.     UpdateCheck;
  204.   end;
  205. end;
  206.  
  207. procedure FCSDlg.CMNew(var Msg: TMessage);
  208. begin
  209.   GetIniData(TransferBuffer, '_default');
  210.   {StrCopy(SctnName, 'noname');}
  211.   SctnName[0] := #0;
  212.   TransferData(tf_SetData);
  213.   SetTitle;
  214.   UpdateCheck;
  215.   ItmLabel^.SetText('Not yet installed');
  216.   GrpLabel^.SetText('');
  217. end;
  218.  
  219. procedure FCSDlg.CMOpen(var Msg: TMessage);
  220. var
  221.     Buffer: array[0..PrgManItm] of Char;
  222.   PD: PDialog;
  223. begin
  224.     PD := New(PSctnDlg, Init(@Self, Buffer, Sizeof(Buffer)));
  225.   if Application^.ExecDialog(PD) = id_Ok then
  226.     begin
  227.       StrCopy(SctnName, Buffer);
  228.       GetIniData(TransferBuffer, SctnName);
  229.     TransferData(tf_SetData);
  230.     SetTitle;
  231.     UpdateCheck;
  232.     ClearModFlags;
  233.   end;
  234. end;
  235.  
  236. procedure FCSDlg.ClearModFlags;
  237. begin
  238.     DirEdit^.ClearModify;
  239.   FltrEdit^.ClearModify;
  240.   PrmEdit^.ClearModify;
  241.     AppEdit^.ClearModify;
  242.     NeedsAppIsChecked := NeedsAppCheck^.GetCheck;
  243.   MinIsChecked := MinRadio^.GetCheck;
  244.   WinIsChecked := WinRadio^.GetCheck;
  245.   MaxIsChecked := MaxRadio^.GetCheck;
  246.   NewInstall := FALSE;
  247. end;
  248.  
  249. procedure FCSDlg.CMSave(var Msg: TMessage);
  250. begin
  251.   if SctnName[0] = #0 then
  252.       CMSaveAs(Msg)
  253.   else
  254.   begin
  255.         SetIniData(SctnName);
  256.       ClearModFlags;
  257.   end;
  258. end;
  259.  
  260. procedure FCSDlg.CMInstall(var Msg: TMessage);
  261. var
  262.     PD: PDialog;
  263.   PItm: array[0..PrgManItm] of Char;
  264.   PGrp: array[0..PrgManGrp] of Char;
  265. begin
  266.     PD := New(PInstallDlg, Init(@Self, SctnName, PItm, PGrp));
  267.   if Application^.ExecDialog(PD) = id_Ok then
  268.   begin
  269.     ItmLabel^.SetText(PItm);
  270.     GrpLabel^.SetText(PGrp);
  271.     NewInstall := TRUE;
  272.   end; 
  273. end;
  274.  
  275. procedure FCSDlg.CMSaveAs(var Msg: TMessage);
  276. var
  277.     PItm: array[0..PrgManItm] of Char;
  278.   PGrp: array[0..PrgManGrp] of Char;
  279.     PD: PDialog;
  280. begin
  281.     StrCopy(PItm, SctnName);
  282.   PD := New(PSaveAsDlg, Init(@Self, PItm));
  283.   if Application^.ExecDialog(PD) = id_Ok then
  284.   begin
  285.       StrCopy(SctnName, PItm);
  286.       FixName(SctnName);
  287.         GetPrivateProfileString(SctnName, 'ITEMNAME', 'Not yet installed',
  288.       PItm, PrgManItm+1, IniName);
  289.     GetPrivateProfileString(SctnName, 'GROUPNAME', '', PGrp,
  290.         PrgManGrp+1, IniName);
  291.     ItmLabel^.SetText(PItm);
  292.     GrpLabel^.SetText(PGrp);
  293.       SetIniData(SctnName);
  294.     SetTitle;
  295.       ClearModFlags;
  296.   end;
  297. end;
  298.  
  299. procedure FCSDlg.CMUse(var Msg: TMessage);
  300. begin
  301.   FCSDlg.TransferData(tf_GetData);
  302.   if Can